public class Person
{
    public String name;
    public MyDate birthdate;
    public String gender, province, city;
    private static int count=0;

    public Person(String name,MyDate birthdate,String gender,String province,String city)
    {
        this.set(name,birthdate,gender,province,city);
        ++count;
    }

    public Person(String name,MyDate birthdate)
    {
        this(name,birthdate,"","","");
    }

    public Person()
    {
        this("",new MyDate());
    }

    public Person(Person per)
    {
        this(per.name,new MyDate(per.birthdate),per.gender,per.province,per.city);
    }

    public void finalize()
    {
        System.out.println("释放对象("+this.toString()+")");
        Person.count--;
    }

    public static void howMany()
    {
        System.out.print(Person.count+"个Person对象,");
    }

    public void set(String name,MyDate birthdate,String gender,String province,String city)
    {
        this.name=name==null?"":name;
        this.birthdate=birthdate;
        this.gender=gender==null?"":gender;
        this.province=province==null?"":province;
        this.city=city==null?"":city;
    }

    public void set(String name,MyDate birthdate)
    {
        this.set(name,birthdate,"","","");
    }

    public String toString()
    {
        return this.name+","+(this.birthdate==null?"":birthdate.toString())+","+this.gender+","+this.province+","+this.city;
    }

    public boolean compareByName(String name)
    {
        return this.name.equals(name);
    }

    public boolean compareByLastName(char lastName)
    {
        return this.name.charAt(0)==lastName;
    }

    public boolean compareByBirthYear(int year)
    {
        return this.birthdate.compareByYear(year);
    }

    public boolean compareByProvince(String province)
    {
        return this.province.equals(province);
    }

    public boolean compareByProvinceAndCity(String province,String city)
    {
        return this.province.equals(province)&&this.city.equals(city);
    }
}
